class Channel < ApplicationRecord
  mount_uploader :avatar, BaseUploader
  mount_uploader :share_avatar, BaseUploader

  has_many :spus

  validates :name, presence: { message: "名字不能为空" }
  validates :page_type, presence: { message: "跳转类型不能为空" }

  belongs_to :parent, class_name: 'Channel', foreign_key: 'parent_id', optional: true
  has_many :children, class_name: 'Channel', foreign_key: 'parent_id'
end
